package avicit.bdp.dds.server.master.dispatch.executor;

import avicit.bdp.dds.server.master.dispatch.context.ExecutionContext;
import avicit.bdp.dds.server.master.dispatch.exceptions.ExecuteException;

/**
 *  executor manager
 */
public interface ExecutorManager<T> {

    /**
     * before execute
     *
     * @param executeContext executeContext
     * @throws ExecuteException if error throws ExecuteException
     */
    void beforeExecute(ExecutionContext executeContext) throws ExecuteException;

    /**
     * execute task
     * @param context context
     * @return T
     * @throws ExecuteException if error throws ExecuteException
     */
    T execute(ExecutionContext context) throws ExecuteException;

    /**
     * execute task directly without retry
     * @param context context
     * @throws ExecuteException if error throws ExecuteException
     */
    void executeDirectly(ExecutionContext context) throws ExecuteException;

    /**
     *  after execute
     * @param context context
     * @throws ExecuteException if error throws ExecuteException
     */
    void afterExecute(ExecutionContext context) throws ExecuteException;
}
